package com.edu.bean;

import java.util.List;

public class Page<T> {
	private List<T> data;
	private boolean hasNext;
	private boolean hasPrev;
	private int pageNum;
	private int pageSize;
	private int totalRows;
	private int totalPage;
	public List<T> getData() {
		return data;
	}
	public void setData(List<T> data) {
		this.data = data;
	}
	public boolean isHasNext() {
		return hasNext;
	}
	public void setHasNext(boolean hasNext) {
		this.hasNext = hasNext;
	}
	public boolean isHasPrev() {
		return hasPrev;
	}
	public void setHasPrev(boolean hasPrev) {
		this.hasPrev = hasPrev;
	}
	public int getPageNum() {
		return pageNum;
	}
	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public int getTotalRows() {
		return totalRows;
	}
	public void setTotalRows(int totalRows) {
		this.totalRows = totalRows;
	}
	public int getTotalPage() {
		return totalPage;
	}
	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}
	public Page() {
		
	}
	public Page(List<T> data, int pageNum, int pageSize, int totalRows) {
		super();
		this.data = data;
		this.pageNum = pageNum;
		this.pageSize = pageSize;
		this.totalRows = totalRows;
		this.totalPage=totalRows%pageSize==0?totalRows/pageSize:(totalRows/pageSize)+1;
		if(pageNum<=1) {
			this.hasPrev=false;
		}else {
			this.hasPrev=true;
		}
		if(pageNum>=totalPage) {
			this.hasNext=false;
		}else {
			this.hasNext=true;
		}
	}
	
}
